<template>
	<view class="appoinent-item" v-if="isTreasure">
		<view class="header1">
			<text class="name">{{datasource.treasure_name}}</text>
			<text class="type">{{datasource.audit_status_text}}</text>
		</view>
		<view class="group">
			<view class="item">
				<text>姓名</text>
				<text>{{datasource.user_name}}</text>
			</view>
			<view class="item">
				<text>联系电话</text>
				<text>{{datasource.user_phone}}</text>
			</view>
			<view class="item">
				<text>预约时间</text>
				<text>{{datasource.appointment_date}}</text>
			</view>
			<view class="item">
				<text>鉴宝地址</text>
				<text class="line1" style="width: 370upx;text-align: right;">{{datasource.address_detail}}</text>
			</view>
		</view>
		<view class="bottom">
			<view class="row-crnter">
				<text class="commint-time">提交时间</text>
				<text class="time">{{datasource.created_at}}</text>
			</view>
			<view class="cancel-btn" @click="cancelTreasure(datasource.id)" v-if="datasource.audit_status==0">取消预约</view>
		</view>
	</view>
	<view class="appoinent-item" v-else>
		<view class="header1">
			<text class="name">{{datasource.treasure_name}}</text>
			<text class="type">{{datasource.audit_status_text}}</text>
		</view>
		<view class="group">
			<view class="item">
				<text>姓名</text>
				<text>{{datasource.user_name}}</text>
			</view>
			<view class="item">
				<text>联系电话</text>
				<text>{{datasource.user_phone}}</text>
			</view>
			<view class="item">
				<text>预约时间</text>
				<text>{{datasource.appointment_date}}</text>
			</view>
			<!-- <view class="item">
				<text>鉴宝地址</text>
				<text class="line1" style="width: 370upx;text-align: right;">上海市长宁区宣化路28号…</text>
			</view> -->
		</view>
		<view class="bottom">
			<view class="row-crnter">
				<text class="commint-time">提交时间</text>
				<text class="time">{{datasource.created_at}}</text>
			</view>
			<view class="cancel-btn" @click="cancelAppoietment(datasource.id)" v-if="datasource.audit_status==0">取消预约</view>
		</view>
	</view>
</template>

<script>
	import {
		cancelJudge,
		cancelTransfer
	} from '@/api/peopleHide.js'
	export default {
		props: {
			datasource: {
				type: Object,
				default: function() {
					return {};
				}
			},
			isTreasure: {
				type: Boolean,
				default: false
			}
		},
		data() {
			return {

			}
		},
		methods: {
			cancelTreasure(e) { //取消鉴宝预约
				let that = this
				uni.showModal({
					title: '提示',
					content: '取消该预约？',
					success(res) {
						if (res.confirm) {
							cancelJudge({
								id: e
							}).then(res => {
								that.$emit('cancelAppointment')
							})
						}
					}
				})

			},
			cancelAppoietment(e) { //取消过户预约
				let that = this
				uni.showModal({
					title: '提示',
					content: '取消该预约？',
					success(res) {
						if (res.confirm) {
							cancelTransfer({
								id: e
							}).then(res => {
								that.$emit('cancelAppointment')
							})
						}
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	.appoinent-item {
		display: flex;
		flex-direction: column;
		background-color: #fff;
		width: 690upx;
		margin: 20upx auto;
		border-radius: 12upx;
		padding: 0 20upx;
		box-sizing: border-box;
		overflow: hidden;

		.header1 {
			width: 100%;
			height: 104upx;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.name {
				color: #333333;
				font-size: 32upx;
				font-weight: 500;
			}

			.type {
				color: #0091FF;
				font-size: 28upx;
				font-weight: 500;
			}
		}
	}

	.group {
		width: 100%;
		display: flex;
		flex-direction: column;

		.item {
			display: flex;
			align-items: center;
			justify-content: space-between;
			color: #333333;
			font-size: 28upx;
			background: rgba(94, 196, 202, 0.10);
			border-radius: 8upx;
			width: 100%;
			height: 72upx;
			margin-bottom: 10upx;
			padding: 0 20upx;
			box-sizing: border-box;
		}
	}

	.bottom {
		width: 100%;
		height: 100upx;
		margin-top: 10upx;
		border-top: 1px solid#E6E6E6;
		display: flex;
		align-items: center;
		justify-content: space-between;

		.row-crnter {
			display: flex;
			align-items: center;

			.commint-time {
				color: #666;
				font-size: 24upx;
				margin-right: 20upx;
			}

			.time {
				color: #FF401A;
				font-size: 28upx;
				font-weight: 500;
			}
		}

		.cancel-btn {
			display: flex;
			align-items: center;
			justify-content: center;
			width: 152upx;
			height: 60upx;
			opacity: 1;
			background: #0091ff;
			border-radius: 38upx;
			color: #fff;
			font-size: 28upx;
		}
	}
</style>
